﻿#include "orderformcontent.h"
#include "ui_orderformcontent.h"
#include "mydate.h"
#include <QDate>

OrderFormContent::OrderFormContent(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::OrderFormContent)
{
    ui->setupUi(this);
    m_reserveInfo = GlobalVars::g_localReserve;

    initWindowsUnits();
}

OrderFormContent::~OrderFormContent()
{
    delete ui;
}

void OrderFormContent::initWindowsUnits()
{
    ui->lb_house->setText(QString::number(m_reserveInfo.getHouseCount()) + "间  " + m_reserveInfo.getHouseType());
    ui->lb_price->setText("¥" + QString::number(m_reserveInfo.getPayment()) + ".00");
    ui->lb_time->setText(m_reserveInfo.getCheckInTime() + " - " + m_reserveInfo.getCheckOutTime());

    ui->pb_hotelName->setText(m_reserveInfo.getHotelName());
}

void OrderFormContent::setHaveComented()
{
    ui->pb_comment->setText("已评论");
    ui->pb_comment->setEnabled(false);
    ui->pb_comment->setStyleSheet("border:0px solid #13D1BE;");
}

void OrderFormContent::setImage(const QImage& image)
{
    ui->lb_image->setPixmap(QPixmap::fromImage(image.scaled(170,110)));
}

QString OrderFormContent::getReserveId()
{
    return m_reserveInfo.getReserve();
}


/// 点击去评价
void OrderFormContent::on_pb_comment_clicked()
{
    QStringList strList;
    strList << m_reserveInfo.getHotel()
            << m_reserveInfo.getHotelName()
            << m_reserveInfo.getHouseType()
            << m_reserveInfo.getCheckInTime()
            << m_reserveInfo.getReserve();

    emit signalCommentReserve(strList);
}

/// 点击查看订单详情
void OrderFormContent::on_pb_hotelName_clicked()
{
    emit signalReserveDetails(m_reserveInfo.getReserve());
}


void OrderFormContent::on_pb_image_clicked()
{
    on_pb_hotelName_clicked();
}
